#include "LicenseProxy.h"
#include "../../XmlTool/XmlTool.h"
USING_XML_BIND

LICENSE_PROXY_NAMESPACE_BEGIN

struct tLicenseRequestInfo : public tBaseRequestInfo {
	tLicenseInfo license;
};

struct tLicenseActiveRequestInfo : public tLicenseRequestInfo {
	tMachineInfoList machineInfo;
};

struct tLicenseCheckResponseInfo : public tBaseResponseInfo {
	int resultCode;
};

struct tLicenseActiveResponseInfo : public tBaseResponseInfo {
	tActiveCodeList activeCode;
};

class LicenseInfoXmlBinding : public AbstractObjectXmlBinding<tLicenseInfo, LicenseInfoXmlBinding> 
{
public:
	const XmlBindingOption<tLicenseInfo>* GetXmlBindingOption() const
	{
		static const XmlBinding<tLicenseInfo>* const bindingInfo[] = {
			new AttrObjXmlBinding<tLicenseInfo, string>("sn", &tLicenseInfo::serialNumber),
			new AttrObjXmlBinding<tLicenseInfo, unsigned short>("product_id", &tLicenseInfo::product_id),
		};
		static XmlBindingOption<tLicenseInfo> option = {
			"LicenseInfo", bindingInfo, sizeof(bindingInfo) / sizeof(const XmlBinding<tLicenseInfo>*),
		};
		return &option;
	}
}; 

class MachineInfoXmlBinding : public AbstractObjectXmlBinding<tMachineInfo, MachineInfoXmlBinding> 
{
public:
	const XmlBindingOption<tMachineInfo>* GetXmlBindingOption() const
	{
		static const XmlBinding<tMachineInfo>* const bindingInfo[] = {
			new AttrObjXmlBinding<tMachineInfo, unsigned int>("info", &tMachineInfo::info),
			new AttrObjXmlBinding<tMachineInfo, HardwareInfoType>("type", &tMachineInfo::type),
		};
		static XmlBindingOption<tMachineInfo> option = {
			"MachineInfo", bindingInfo, sizeof(bindingInfo) / sizeof(const XmlBinding<tMachineInfo>*),
		};
		return &option;
	}
};

class ActiveCodeInfoXmlBinding : public AbstractObjectXmlBinding<tActiveCodeInfo, ActiveCodeInfoXmlBinding> 
{
public:
	const XmlBindingOption<tActiveCodeInfo>* GetXmlBindingOption() const
	{
		static const XmlBinding<tActiveCodeInfo>* const bindingInfo[] = {
			new AttrObjXmlBinding<tActiveCodeInfo, string>("active_code", &tActiveCodeInfo::active_code),
			new AttrObjXmlBinding<tActiveCodeInfo, HardwareInfoType>("type", &tActiveCodeInfo::type),
		};
		static XmlBindingOption<tActiveCodeInfo> option = {
			"ActiveCodeInfo", bindingInfo, sizeof(bindingInfo) / sizeof(const XmlBinding<tActiveCodeInfo>*),
		};
		return &option;
	}
};

class LicenseRequestXmlBinding : public AbstractPolymorphicObjectXmlBinding
								<tLicenseRequestInfo, LicenseRequestXmlBinding, tBaseRequestInfo, BaseRequestXmlBinding> 
{
public:
	const XmlBindingOption<tLicenseRequestInfo>* GetXmlBindingOption() const
	{
		static RefMemberTraits<tLicenseRequestInfo, tLicenseInfo> licenseMember(&tLicenseRequestInfo::license);
		static const XmlBinding<tLicenseRequestInfo>* const bindingInfo[] = {
			new MemberChildNodeXmlBinding<tLicenseRequestInfo, tLicenseInfo, LicenseInfoXmlBinding>(&licenseMember),
		};
		static XmlBindingOption<tLicenseRequestInfo> option = {
			"LicenseRequest", bindingInfo, sizeof(bindingInfo) / sizeof(const XmlBinding<tLicenseRequestInfo>*),
		};
		return &option;
	}
};  

class LicenseActiveRequestXmlBinding : public AbstractPolymorphicObjectXmlBinding
										<tLicenseActiveRequestInfo, LicenseActiveRequestXmlBinding, tLicenseRequestInfo, LicenseRequestXmlBinding> 
{
public:
	const XmlBindingOption<tLicenseActiveRequestInfo>* GetXmlBindingOption() const
	{
		static RefMemberTraits<tLicenseActiveRequestInfo, tMachineInfoList> machineMember(&tLicenseActiveRequestInfo::machineInfo);

		static const XmlBinding<tLicenseActiveRequestInfo>* const bindingInfo[] = {
			new StlRefObjContainerChildNodeXmlBinding<tLicenseActiveRequestInfo, tMachineInfo, list, MachineInfoXmlBinding>("MachineInfo", &machineMember),
		};
		static XmlBindingOption<tLicenseActiveRequestInfo> option = {
			"LicenseActiveRequest", bindingInfo, sizeof(bindingInfo) / sizeof(const XmlBinding<tLicenseActiveRequestInfo>*),
		};
		return &option;
	}
};  

class LicenseCheckResponseXmlBinding : public AbstractPolymorphicObjectXmlBinding
										<tLicenseCheckResponseInfo, LicenseCheckResponseXmlBinding, tBaseResponseInfo, BaseResponseXmlBinding> 
{
public:
	const XmlBindingOption<tLicenseCheckResponseInfo>* GetXmlBindingOption() const
	{
		static const XmlBinding<tLicenseCheckResponseInfo>* const bindingInfo[] = {
			new AttrObjXmlBinding<tLicenseCheckResponseInfo, int>("result_code", &tLicenseCheckResponseInfo::resultCode),
		};
		static XmlBindingOption<tLicenseCheckResponseInfo> option = {
			"LicenseCheckResponse", bindingInfo, sizeof(bindingInfo) / sizeof(const XmlBinding<tLicenseCheckResponseInfo>*),
		};
		return &option;
	}
};  

class LicenseActiveResponseXmlBinding : public AbstractPolymorphicObjectXmlBinding
										<tLicenseActiveResponseInfo, LicenseActiveResponseXmlBinding, tBaseResponseInfo, BaseResponseXmlBinding> 
{
public:
	const XmlBindingOption<tLicenseActiveResponseInfo>* GetXmlBindingOption() const
	{
		static RefMemberTraits<tLicenseActiveResponseInfo, tActiveCodeList> activeMember(&tLicenseActiveResponseInfo::activeCode);

		static const XmlBinding<tLicenseActiveResponseInfo>* const bindingInfo[] = {
			new StlRefObjContainerChildNodeXmlBinding<tLicenseActiveResponseInfo, tActiveCodeInfo, list, ActiveCodeInfoXmlBinding>("ActiveCode", &activeMember),
		};
		static XmlBindingOption<tLicenseActiveResponseInfo> option = {
			"LicenseActiveResponse", bindingInfo, sizeof(bindingInfo) / sizeof(const XmlBinding<tLicenseActiveResponseInfo>*),
		};
		return &option;
	}
};  

LICENSE_PROXY_NAMESPACE_END